package com.example.demo.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author: xiatian
 * @CreateTime: 2022/2/26 9:01 下午
 * @Description:
 */
public class CallableDemo implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println("---------callable come in");
        return 1024;
    }
}

class MyThread {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask task = new FutureTask(new CallableDemo());
        Thread t1 = new Thread(task, "AA");
        t1.start();
//        while (!task.isDone()) {
//
//        }


        Object result = task.get();
        System.out.println(result.toString());

    }
}
